//引入三级联动发送请求
import {reqCategoryList,reqgetBanner, reqgetFloor,} from '../../api/index'
const state={ 
   categoryList:[],
   bannerList:[],
   floorList:[],

}
const actions={
   //1.通过API里面的接口调用，向服务器发送请求，获取服务器的数据
   categoryList(context){
      let result =reqCategoryList()
      result.then(Request=>{
         if(Request.code===200){
         context.commit('CATEGORYLIST',Request.data)
         }
      },error=>{
         console.log(error.message)
      })
   },

   //2.获得首页轮播图数据
   getBanner(context){
      let result =reqgetBanner()
      result.then(Request=>{
         if(Request.code===200){
         context.commit('GETBANNER',Request.data)
         }
      },error=>{
         console.log("找不到轮播图文件！"+error.message)
      })
   },

   //3.获取首页楼层数据
   getFloor(context){
      let result =reqgetFloor()
      result.then(Request=>{
         if(Request.code===200){
         context.commit('GETFLOOR',Request.data)
       
         }
      },error=>{
         console.log("找不到楼层文件！"+error.message)
      })
   },
}
const mutations={
   CATEGORYLIST(state,value){
     state.categoryList=value
   },
   GETBANNER(state,value){
      state.bannerList=value
   },
   GETFLOOR(state,value){
      state.floorList=value
   },
 
}
const getters={}
export default{
   state,actions,mutations,getters
}
